<template>
	<div class="box">
		<!-- <el-button type="primary" size="default" @click="a">123</el-button> -->

		<div class="title">合同</div>
		<div class="container">
			<FormItems
				ref="form"
				v-model="formData"
				:form="formList"
				:state="state"></FormItems>
		</div>
	</div>
</template>

<script>
	import FormItems from '@/views/finance/manage/formItems/index.vue';
	import FormItem from '@/views/finance/reimburs/formItem/index.vue';
	export default {
		components: { FormItems, FormItem },
		dicts: ['quota_outsourcing', 'quota_source_business'],
		props: {
			value: {
				required: false,
			},
			state: {
				required: false,
			},
			type: {
				required: false,
			},
		},
		inject: ['_dicts', 'details_config', '_from'],
		data() {
			return {};
		},
		computed: {
			formData: {
				get() {
					return this.value;
					return this.useVModel.call(this);
				},
				set(val) {
					this.$emit('input', val);
				},
			},
			dicts() {
				return this._dicts();
			},
			config() {
				return this.details_config();
			},
			carTypeList() {
				let arr = [
					{
						label: '新车',
						value: '1',
					},
					{
						label: '旧车',
						value: '2',
					},
				];
				if (this.notEmpty(this.config.vehicleSource)) {
					let planCarType = '';
					switch (this.config.vehicleSource?.toString()) {
						case '1':
							planCarType = '1';
							break;
						case '2':
							planCarType = '2';
							break;
						case '3':
							planCarType = '2';
							break;
						default:
							break;
					}
					arr.forEach(item => {
						if (item.value !== planCarType) {
							item.disabled = true;
						}
					});
				}
				return arr;
			},
			carSourceTypeList() {
				let arr = [
					{
						label: '自购',
						value: '1',
					},
					{
						label: '现有',
						value: '2',
					},
					{
						label: '外部转租赁',
						value: '3',
					},
				];
				if (this.formData.carType == '1') {
					arr.splice(1, 1);
				}
				if (this.notEmpty(this.config.vehicleSource)) {
					let planCarSourceType = '';
					switch (this.config.vehicleSource?.toString()) {
						case '1':
							planCarSourceType = '1';
							break;
						case '2':
							planCarSourceType = '2';
							break;
						case '3':
							planCarSourceType = '1';
							break;
						default:
							break;
					}
					arr.forEach((item, index) => {
						if (
							item.value !== '3' &&
							item.value !== planCarSourceType
						) {
							item.disabled = true;
						}
					});
				}
				return arr;
			},
			formList() {
				return [
					{
						label: '合同模板方案',
						type: 'radioGroup',
						prop: 'a',
						radioGroupList: [
							{
								label: '续租合同模板',
								value: 0,
							},
						],
						formitemPrototype: {
							style: {
								width: '100%',
							},
						},
					},
					{
						label: '租赁模板方案',
						type: 'select',
						prop: 'b',
						selectList: [
							{
								label: '续租合同模板',
								value: 0,
							},
						],
						formitemPrototype: {
							style: {
								width: '100%',
							},
						},
					},
				];
			},
		},
		created() {},
		mounted() {},
		methods: {
			a() {
				console.log(this.formData);
			},
			setDisabled() {},
			valid() {
				return new Promise(resolve => {
					this.$refs.form.form_validate(valid => resolve(valid));
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.box {
		margin: 20px;
		padding: 20px;
		border-radius: 8px;
		background-color: #fff;
		.title {
			font-size: 16px;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 22px;
			padding-bottom: 15px;
			border-bottom: 1px solid #e9e9e9;
			margin-bottom: 15px;
		}
	}
</style>
